<template>
	<view>

		<view class="top">
			<u-search animation :action-style="{color:'#fff'}" bg-color="#fff" shape="square" placeholder="搜索你想要的工作"
				v-model="initial.parm.keyword" @custom="search" @search="search"></u-search>
		</view>

		<u-dropdown ref="uDropdown" border-bottom>
			<city @close="close" @select='select' @province="province"></city>
			<work @Sjob="Sjob" :dropTitle="dropTitle"></work>
		</u-dropdown>


		<u-gap height="5" bg-color="#f1f1f1"></u-gap>


		<u-cell-item :arrow="false" :border-bottom="false">
			<view slot='icon'>
				<u-icon name='kefu-ermai' size="35" color="#3C97FF"></u-icon>
			</view>
			<view slot='title' style="margin-left: 20rpx">
				客服电话:{{kfTel}}
			</view>
			<u-button plain type="primary" size="mini" slot="right-icon" @click='kfcall'>
				联系客服
			</u-button>
		</u-cell-item>

		<u-gap height="5" bg-color="#f1f1f1"></u-gap>

		<u-cell-item v-if="!info.role" :border-bottom="false" @click="goCertification">
			<view slot='icon'>
				<u-icon name='man-add' size="35" color="#3C97FF"></u-icon>
			</view>
			<view slot='title' style="margin-left: 20rpx">
				完成实名认证，信息优先推荐
			</view>
		</u-cell-item>


		<u-gap height="5" bg-color="#f1f1f1"></u-gap>


		<workList :list="list" v-if='list.length'></workList>
		
		
		<identityBtn></identityBtn>
	</view>

</template>

<script>
	import loader from '@/common/loadPage.js';
	import {
		mapState,
		mapMutations
	} from 'vuex';

	import city from './components/city.vue';
	import work from './components/work.vue';

	export default {
		mixins: [loader],
		components: {
			city,
			work
		},

		data() {
			return {
				info: {},
				initial: {
					geturl: "/index/job",

					parm: {
						city: '',
						work_id: '',
						keyword: "",
						type: 2,
						province: ''

					},
					isPage: true
				},
				dropTitle: '',
				list: [],
				kfTel: ""

			}
		},
		computed: {
			...mapState(['userAddress', 'ClassIndex'])
		},
		onLoad() {



		},
		onShow() {

			this.$u.api.userInfo().then(res => {
				this.info = res;
			})


			if (this.ClassIndex.id) {
				this.initial.parm.work_id = this.ClassIndex.id;

				this.dropTitle = this.ClassIndex.workName;
			}

			if (this.userAddress) {
				this.initial.parm.city = this.userAddress
			}
			this.get()
			this.getConfig()
		},
		methods: {

			goCertification() {
				uni.navigateTo({
					url: '/pages/certification/index'
				})
			},
			kfcall() {
				uni.makePhoneCall({
					phoneNumber: this.kfTel
				})
			},
			getConfig() {
				this.$u.api.getConfig().then(res => {
					this.kfTel = res.kfTel;
				})
			},
			search(e) {
				this.get()
			},
			province(e) {
				this.initial.page = 1;
				this.initial.parm.city = '';
				this.initial.parm.province = e=='全国'?'':e;
				this.get()
				this.$refs.uDropdown.close();
			},
			select(e) {
				this.initial.page = 1;
				this.initial.parm.province = '';
				this.initial.parm.city = e;
				this.get()
				this.$refs.uDropdown.close();

			},
			Sjob(e) {
				console.log(e,"rrr")
				this.initial.page = 1;
				this.initial.parm.work_id = e;
				this.get()
				this.$refs.uDropdown.close();
			},
			close() {
				this.initial.page = 1;
				this.initial.parm.city = '';
				this.get()
				this.$refs.uDropdown.close();
			},

			get() {
				this.getGoods().then(res => {
					this.list = res;
				})
			}

		}
	}
</script>

<style>
	.top {
		background: #3C97FF;
		padding: 30rpx;

	}
</style>
